﻿using Hallenberg.Core.Globalization;
using Hallenberg.SmartClient.Menu;
using NUnit.Framework;

namespace Hallenberg.SmartClient.Test.Menu
{
    [TestFixture]
    public class LocalizationTests
    {
        [Test]
        public void ShouldReturnTheNameWithoutAnyLookups()
        {
            const string ToolTip = "The Tooltip";
            const string Title = "The Menu Title";
            const string MenuName = "Menu Item Name";

            var menuItem = new MenuItem(MenuName, Title, ToolTip);

            Assert.That(menuItem.MenuItemTitle, Is.EqualTo(Title));
        }

        [Test]
        public void ShouldReturnTheResourceBasedName()
        {
            const string ToolTip = "The Tooltip";
            const string MenuName = "Menu Item Name";
            const string ExpectedResourceBasedMenuTitle = "The Menu Title";
            const string ResourceBasedMenuTitleKey = "TestMenuTitle";

            using (ChangeThreadCulture change = new ChangeThreadCulture("en-US"))
            {
                var menuItem = new MenuItem(MenuName, string.Empty, ToolTip)
                {
                    TitleResourceName = ResourceBasedMenuTitleKey,
                    TitleResourceType = typeof(Properties.Resources)
                };

                Assert.That(menuItem.MenuItemTitle, Is.EqualTo(ExpectedResourceBasedMenuTitle));
            }
        }
    }
}
